@ibiz-template-plugin/ibiz-file-previewer 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +234 -59
- package/dist/index.legacy.js +1 -1
- package/dist/style.css +2 -2
- package/dist/types/src/component/file-preview-item/file-preview-image-group/image-page/image-page.d.ts +4 -0
- package/dist/types/src/controller/file-preview-item/file-prview-html-controller.d.ts +4 -0
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -2,7 +2,7 @@ import './style.css';
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
var n$1, l$3, u$3, t$2, i$2, o$2, r$1, e$2, f$3, c$2, s$3, a$2, p$3 = {}, v$3 = [], y$2 = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, d$
|
|
5
|
+
var n$1, l$3, u$3, t$2, i$2, o$2, r$1, e$2, f$3, c$2, s$3, a$2, p$3 = {}, v$3 = [], y$2 = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, d$3 = Array.isArray;
|
|
6
6
|
function w$2(n2, l2) {
|
|
7
7
|
for (var u2 in l2) n2[u2] = l2[u2];
|
|
8
8
|
return n2;
|
|
@@ -55,8 +55,8 @@ function I(n2, l2, u2, t2, i2, o2, r2, e2, f2, c2, s2) {
|
|
|
55
55
|
}
|
|
56
56
|
function P$1(n2, l2, u2, t2, i2) {
|
|
57
57
|
var o2, r2, e2, f2, c2, s2 = u2.length, a2 = s2, h2 = 0;
|
|
58
|
-
for (n2.__k = new Array(i2), o2 = 0; o2 < i2; o2++) null != (r2 = l2[o2]) && "boolean" != typeof r2 && "function" != typeof r2 ? ("string" == typeof r2 || "number" == typeof r2 || "bigint" == typeof r2 || r2.constructor == String ? r2 = n2.__k[o2] = m$1(null, r2, null, null, null) : d$
|
|
59
|
-
if (a2) for (o2 = 0; o2 < s2; o2++) null != (e2 = u2[o2]) && 0 == (2 & e2.__u) && (e2.__e == t2 && (t2 = S(e2)), D(e2, e2));
|
|
58
|
+
for (n2.__k = new Array(i2), o2 = 0; o2 < i2; o2++) null != (r2 = l2[o2]) && "boolean" != typeof r2 && "function" != typeof r2 ? ("string" == typeof r2 || "number" == typeof r2 || "bigint" == typeof r2 || r2.constructor == String ? r2 = n2.__k[o2] = m$1(null, r2, null, null, null) : d$3(r2) ? r2 = n2.__k[o2] = m$1(k$1, { children: r2 }, null, null, null) : void 0 === r2.constructor && r2.__b > 0 ? r2 = n2.__k[o2] = m$1(r2.type, r2.props, r2.key, r2.ref ? r2.ref : null, r2.__v) : n2.__k[o2] = r2, f2 = o2 + h2, r2.__ = n2, r2.__b = n2.__b + 1, e2 = null, -1 != (c2 = r2.__i = L(r2, u2, f2, a2)) && (a2--, (e2 = u2[c2]) && (e2.__u |= 2)), null == e2 || null == e2.__v ? (-1 == c2 && (i2 > s2 ? h2-- : i2 < s2 && h2++), "function" != typeof r2.type && (r2.__u |= 4)) : c2 != f2 && (c2 == f2 - 1 ? h2-- : c2 == f2 + 1 ? h2++ : (c2 > f2 ? h2-- : h2++, r2.__u |= 4))) : n2.__k[o2] = null;
|
|
59
|
+
if (a2) for (o2 = 0; o2 < s2; o2++) null != (e2 = u2[o2]) && 0 == (2 & e2.__u) && (e2.__e == t2 && (t2 = S(e2)), D$1(e2, e2));
|
|
60
60
|
return t2;
|
|
61
61
|
}
|
|
62
62
|
function A$1(n2, l2, u2, t2) {
|
|
@@ -72,7 +72,7 @@ function A$1(n2, l2, u2, t2) {
|
|
|
72
72
|
return l2;
|
|
73
73
|
}
|
|
74
74
|
function H$1(n2, l2) {
|
|
75
|
-
return l2 = l2 || [], null == n2 || "boolean" == typeof n2 || (d$
|
|
75
|
+
return l2 = l2 || [], null == n2 || "boolean" == typeof n2 || (d$3(n2) ? n2.some(function(n3) {
|
|
76
76
|
H$1(n3, l2);
|
|
77
77
|
}) : l2.push(n2)), l2;
|
|
78
78
|
}
|
|
@@ -139,7 +139,7 @@ function O(n2, u2, t2, i2, o2, r2, e2, f2, c2, s2) {
|
|
|
139
139
|
} else do {
|
|
140
140
|
h2.__d = false, P2 && P2(u2), a2 = h2.render(h2.props, h2.state, h2.context), h2.state = h2.__s;
|
|
141
141
|
} while (h2.__d && ++A2 < 25);
|
|
142
|
-
h2.state = h2.__s, null != h2.getChildContext && (i2 = w$2(w$2({}, i2), h2.getChildContext())), S2 && !p2 && null != h2.getSnapshotBeforeUpdate && (_2 = h2.getSnapshotBeforeUpdate(v2, y2)), L2 = a2, null != a2 && a2.type === k$1 && null == a2.key && (L2 = V$1(a2.props.children)), f2 = I(n2, d$
|
|
142
|
+
h2.state = h2.__s, null != h2.getChildContext && (i2 = w$2(w$2({}, i2), h2.getChildContext())), S2 && !p2 && null != h2.getSnapshotBeforeUpdate && (_2 = h2.getSnapshotBeforeUpdate(v2, y2)), L2 = a2, null != a2 && a2.type === k$1 && null == a2.key && (L2 = V$1(a2.props.children)), f2 = I(n2, d$3(L2) ? L2 : [L2], u2, t2, i2, o2, r2, e2, f2, c2, s2), h2.base = u2.__e, u2.__u &= -161, h2.__h.length && e2.push(h2), m2 && (h2.__E = h2.__ = null);
|
|
143
143
|
} catch (n3) {
|
|
144
144
|
if (u2.__v = null, c2 || null != r2) if (n3.then) {
|
|
145
145
|
for (u2.__u |= c2 ? 160 : 128; f2 && 8 == f2.nodeType && f2.nextSibling; ) f2 = f2.nextSibling;
|
|
@@ -151,7 +151,7 @@ function O(n2, u2, t2, i2, o2, r2, e2, f2, c2, s2) {
|
|
|
151
151
|
else u2.__e = t2.__e, u2.__k = t2.__k, n3.then || z$1(u2);
|
|
152
152
|
l$3.__e(n3, u2, t2);
|
|
153
153
|
}
|
|
154
|
-
else null == r2 && u2.__v == t2.__v ? (u2.__k = t2.__k, u2.__e = t2.__e) : f2 = u2.__e = q$
|
|
154
|
+
else null == r2 && u2.__v == t2.__v ? (u2.__k = t2.__k, u2.__e = t2.__e) : f2 = u2.__e = q$2(t2.__e, u2, t2, i2, o2, r2, e2, c2, s2);
|
|
155
155
|
return (a2 = l$3.diffed) && a2(u2), 128 & u2.__u ? void 0 : f2;
|
|
156
156
|
}
|
|
157
157
|
function z$1(n2) {
|
|
@@ -170,9 +170,9 @@ function N$1(n2, u2, t2) {
|
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
function V$1(n2) {
|
|
173
|
-
return "object" != typeof n2 || null == n2 || n2.__b && n2.__b > 0 ? n2 : d$
|
|
173
|
+
return "object" != typeof n2 || null == n2 || n2.__b && n2.__b > 0 ? n2 : d$3(n2) ? n2.map(V$1) : w$2({}, n2);
|
|
174
174
|
}
|
|
175
|
-
function q$
|
|
175
|
+
function q$2(u2, t2, i2, o2, r2, e2, f2, c2, s2) {
|
|
176
176
|
var a2, h2, v2, y2, w2, _2, m2, b2 = i2.props || p$3, k2 = t2.props, x2 = t2.type;
|
|
177
177
|
if ("svg" == x2 ? r2 = "http://www.w3.org/2000/svg" : "math" == x2 ? r2 = "http://www.w3.org/1998/Math/MathML" : r2 || (r2 = "http://www.w3.org/1999/xhtml"), null != e2) {
|
|
178
178
|
for (a2 = 0; a2 < e2.length; a2++) if ((w2 = e2[a2]) && "setAttribute" in w2 == !!x2 && (x2 ? w2.localName == x2 : 3 == w2.nodeType)) {
|
|
@@ -195,7 +195,7 @@ function q$1(u2, t2, i2, o2, r2, e2, f2, c2, s2) {
|
|
|
195
195
|
}
|
|
196
196
|
for (a2 in k2) w2 = k2[a2], "children" == a2 ? y2 = w2 : "dangerouslySetInnerHTML" == a2 ? h2 = w2 : "value" == a2 ? _2 = w2 : "checked" == a2 ? m2 = w2 : c2 && "function" != typeof w2 || b2[a2] === w2 || j$2(u2, a2, w2, b2[a2], r2);
|
|
197
197
|
if (h2) c2 || v2 && (h2.__html == v2.__html || h2.__html == u2.innerHTML) || (u2.innerHTML = h2.__html), t2.__k = [];
|
|
198
|
-
else if (v2 && (u2.innerHTML = ""), I("template" == t2.type ? u2.content : u2, d$
|
|
198
|
+
else if (v2 && (u2.innerHTML = ""), I("template" == t2.type ? u2.content : u2, d$3(y2) ? y2 : [y2], t2, i2, o2, "foreignObject" == x2 ? "http://www.w3.org/1999/xhtml" : r2, e2, f2, e2 ? e2[0] : i2.__k && S(i2, 0), c2, s2), null != e2) for (a2 = e2.length; a2--; ) g$2(e2[a2]);
|
|
199
199
|
c2 || (a2 = "value", "progress" == x2 && null == _2 ? u2.removeAttribute("value") : null != _2 && (_2 !== u2[a2] || "progress" == x2 && !_2 || "option" == x2 && _2 != b2[a2]) && j$2(u2, a2, _2, b2[a2], r2), a2 = "checked", null != m2 && m2 != u2[a2] && j$2(u2, a2, m2, b2[a2], r2));
|
|
200
200
|
}
|
|
201
201
|
return u2;
|
|
@@ -210,7 +210,7 @@ function B$2(n2, u2, t2) {
|
|
|
210
210
|
l$3.__e(n3, t2);
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
|
-
function D(n2, u2, t2) {
|
|
213
|
+
function D$1(n2, u2, t2) {
|
|
214
214
|
var i2, o2;
|
|
215
215
|
if (l$3.unmount && l$3.unmount(n2), (i2 = n2.ref) && (i2.current && i2.current != n2.__e || B$2(i2, null, u2)), null != (i2 = n2.__c)) {
|
|
216
216
|
if (i2.componentWillUnmount) try {
|
|
@@ -220,7 +220,7 @@ function D(n2, u2, t2) {
|
|
|
220
220
|
}
|
|
221
221
|
i2.base = i2.__P = null;
|
|
222
222
|
}
|
|
223
|
-
if (i2 = n2.__k) for (o2 = 0; o2 < i2.length; o2++) i2[o2] && D(i2[o2], u2, t2 || "function" != typeof n2.type);
|
|
223
|
+
if (i2 = n2.__k) for (o2 = 0; o2 < i2.length; o2++) i2[o2] && D$1(i2[o2], u2, t2 || "function" != typeof n2.type);
|
|
224
224
|
t2 || g$2(n2.__e), n2.__c = n2.__ = n2.__e = void 0;
|
|
225
225
|
}
|
|
226
226
|
function E$2(n2, l2, u2) {
|
|
@@ -253,6 +253,43 @@ function p$2(n2, t2) {
|
|
|
253
253
|
var u2 = r.__H || (r.__H = { __: [], __h: [] });
|
|
254
254
|
return n2 >= u2.__.length && u2.__.push({}), u2.__[n2];
|
|
255
255
|
}
|
|
256
|
+
function d$2(n2) {
|
|
257
|
+
return o$1 = 1, h$1(D, n2);
|
|
258
|
+
}
|
|
259
|
+
function h$1(n2, u2, i2) {
|
|
260
|
+
var o2 = p$2(t$1++, 2);
|
|
261
|
+
if (o2.t = n2, !o2.__c && (o2.__ = [i2 ? i2(u2) : D(void 0, u2), function(n3) {
|
|
262
|
+
var t2 = o2.__N ? o2.__N[0] : o2.__[0], r2 = o2.t(t2, n3);
|
|
263
|
+
t2 !== r2 && (o2.__N = [r2, o2.__[1]], o2.__c.setState({}));
|
|
264
|
+
}], o2.__c = r, !r.__f)) {
|
|
265
|
+
var f2 = function(n3, t2, r2) {
|
|
266
|
+
if (!o2.__c.__H) return true;
|
|
267
|
+
var u3 = o2.__c.__H.__.filter(function(n4) {
|
|
268
|
+
return !!n4.__c;
|
|
269
|
+
});
|
|
270
|
+
if (u3.every(function(n4) {
|
|
271
|
+
return !n4.__N;
|
|
272
|
+
})) return !c2 || c2.call(this, n3, t2, r2);
|
|
273
|
+
var i3 = o2.__c.props !== n3;
|
|
274
|
+
return u3.forEach(function(n4) {
|
|
275
|
+
if (n4.__N) {
|
|
276
|
+
var t3 = n4.__[0];
|
|
277
|
+
n4.__ = n4.__N, n4.__N = void 0, t3 !== n4.__[0] && (i3 = true);
|
|
278
|
+
}
|
|
279
|
+
}), c2 && c2.call(this, n3, t2, r2) || i3;
|
|
280
|
+
};
|
|
281
|
+
r.__f = true;
|
|
282
|
+
var c2 = r.shouldComponentUpdate, e2 = r.componentWillUpdate;
|
|
283
|
+
r.componentWillUpdate = function(n3, t2, r2) {
|
|
284
|
+
if (this.__e) {
|
|
285
|
+
var u3 = c2;
|
|
286
|
+
c2 = void 0, f2(n3, t2, r2), c2 = u3;
|
|
287
|
+
}
|
|
288
|
+
e2 && e2.call(this, n3, t2, r2);
|
|
289
|
+
}, r.shouldComponentUpdate = f2;
|
|
290
|
+
}
|
|
291
|
+
return o2.__N || o2.__;
|
|
292
|
+
}
|
|
256
293
|
function y$1(n2, u2) {
|
|
257
294
|
var i2 = p$2(t$1++, 3);
|
|
258
295
|
!c$1.__s && C(i2.__H, u2) && (i2.__ = n2, i2.u = u2, r.__H.__h.push(i2));
|
|
@@ -266,6 +303,11 @@ function T$1(n2, r2) {
|
|
|
266
303
|
var u2 = p$2(t$1++, 7);
|
|
267
304
|
return C(u2.__H, r2) && (u2.__ = n2(), u2.__H = r2, u2.__h = n2), u2.__;
|
|
268
305
|
}
|
|
306
|
+
function q$1(n2, t2) {
|
|
307
|
+
return o$1 = 8, T$1(function() {
|
|
308
|
+
return n2;
|
|
309
|
+
}, t2);
|
|
310
|
+
}
|
|
269
311
|
function j$1() {
|
|
270
312
|
for (var n2; n2 = f$2.shift(); ) if (n2.__P && n2.__H) try {
|
|
271
313
|
n2.__H.__h.forEach(z), n2.__H.__h.forEach(B$1), n2.__H.__h = [];
|
|
@@ -332,6 +374,9 @@ function C(n2, t2) {
|
|
|
332
374
|
return t3 !== n2[r2];
|
|
333
375
|
});
|
|
334
376
|
}
|
|
377
|
+
function D(n2, t2) {
|
|
378
|
+
return "function" == typeof t2 ? t2(n2) : t2;
|
|
379
|
+
}
|
|
335
380
|
var i = Symbol.for("preact-signals");
|
|
336
381
|
function t() {
|
|
337
382
|
if (!(s$1 > 1)) {
|
|
@@ -913,8 +958,8 @@ var EngineType = /* @__PURE__ */ ((EngineType2) => {
|
|
|
913
958
|
})(EngineType || {});
|
|
914
959
|
const FileTypeEngineMap = /* @__PURE__ */ new Map([
|
|
915
960
|
["html", [
|
|
916
|
-
"
|
|
917
|
-
/*
|
|
961
|
+
"HTML"
|
|
962
|
+
/* HTML */
|
|
918
963
|
]],
|
|
919
964
|
// HTML类型文件
|
|
920
965
|
["md", [
|
|
@@ -1145,18 +1190,16 @@ function u(e2, t2, n2, o2, i2, u2) {
|
|
|
1145
1190
|
return l$3.vnode && l$3.vnode(l2), l2;
|
|
1146
1191
|
}
|
|
1147
1192
|
const FilePreviewHtml = (props) => {
|
|
1193
|
+
const containerRef = A(null);
|
|
1148
1194
|
y$1(() => {
|
|
1195
|
+
if (containerRef.current) {
|
|
1196
|
+
const shadowRoot = containerRef.current.attachShadow({ mode: "open" });
|
|
1197
|
+
const content = '\n <style>\n .content-container {\n height: 100%;\n width: 100%;\n }\n </style>\n <div class="content-container">\n '.concat(props.controller.state.value.content, "\n </div>\n ");
|
|
1198
|
+
shadowRoot.innerHTML = content;
|
|
1199
|
+
}
|
|
1149
1200
|
props.onInitialization();
|
|
1150
1201
|
}, []);
|
|
1151
|
-
return /* @__PURE__ */ u("div", { className: "file-preview-html ".concat(props.controller.state.value.theme), children: /* @__PURE__ */ u(
|
|
1152
|
-
"div",
|
|
1153
|
-
{
|
|
1154
|
-
className: "container",
|
|
1155
|
-
dangerouslySetInnerHTML: {
|
|
1156
|
-
__html: props.controller.state.value.content
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
) });
|
|
1202
|
+
return /* @__PURE__ */ u("div", { className: "file-preview-html ".concat(props.controller.state.value.theme), children: /* @__PURE__ */ u("div", { ref: containerRef, className: "container" }) });
|
|
1160
1203
|
};
|
|
1161
1204
|
const ZoomOutSvg = () => {
|
|
1162
1205
|
return /* @__PURE__ */ u(
|
|
@@ -18244,8 +18287,35 @@ const FilePreviewUnkown = (props) => {
|
|
|
18244
18287
|
"类型预览"
|
|
18245
18288
|
] }) });
|
|
18246
18289
|
};
|
|
18290
|
+
const Loading = ({ size = 24 }) => {
|
|
18291
|
+
return /* @__PURE__ */ u("div", { className: "loading-mask", children: /* @__PURE__ */ u("div", { className: "loading-spinner", children: /* @__PURE__ */ u(LoaddingSvg, { size }) }) });
|
|
18292
|
+
};
|
|
18247
18293
|
const ThumbnailPanel = (props) => {
|
|
18248
18294
|
const contentRef = A(null);
|
|
18295
|
+
const [loadStates, setLoadStates] = d$2({});
|
|
18296
|
+
const ITEM_HEIGHT = 188;
|
|
18297
|
+
const BUFFER_COUNT = 1;
|
|
18298
|
+
const [cachedImages, setCachedImages] = d$2(/* @__PURE__ */ new Set());
|
|
18299
|
+
const [visibleRange, setVisibleRange] = d$2({ start: 0, end: 0 });
|
|
18300
|
+
const calculateVisibleRange = q$1(() => {
|
|
18301
|
+
if (!contentRef.current) return { start: 0, end: 0 };
|
|
18302
|
+
const container = contentRef.current;
|
|
18303
|
+
const scrollTop = container.scrollTop;
|
|
18304
|
+
const containerHeight = container.clientHeight;
|
|
18305
|
+
const start = Math.max(
|
|
18306
|
+
0,
|
|
18307
|
+
Math.floor(scrollTop / ITEM_HEIGHT) - BUFFER_COUNT
|
|
18308
|
+
);
|
|
18309
|
+
const visibleCount = Math.ceil(containerHeight / ITEM_HEIGHT);
|
|
18310
|
+
const end = Math.min(
|
|
18311
|
+
props.pages.length,
|
|
18312
|
+
start + visibleCount + BUFFER_COUNT
|
|
18313
|
+
);
|
|
18314
|
+
return { start, end };
|
|
18315
|
+
}, [props.pages.length]);
|
|
18316
|
+
const updateVisibleRange = q$1(() => {
|
|
18317
|
+
setVisibleRange(calculateVisibleRange());
|
|
18318
|
+
}, [calculateVisibleRange]);
|
|
18249
18319
|
const handleClick = (index, _event) => {
|
|
18250
18320
|
props.onPageClick(index);
|
|
18251
18321
|
};
|
|
@@ -18262,12 +18332,42 @@ const ThumbnailPanel = (props) => {
|
|
|
18262
18332
|
}
|
|
18263
18333
|
}
|
|
18264
18334
|
};
|
|
18335
|
+
const handleImageLoad = (index) => {
|
|
18336
|
+
setLoadStates((prevState) => ({
|
|
18337
|
+
...prevState,
|
|
18338
|
+
[index]: true
|
|
18339
|
+
}));
|
|
18340
|
+
setCachedImages((prev) => new Set(prev).add(index));
|
|
18341
|
+
};
|
|
18342
|
+
const handleImageError = (index, error2) => {
|
|
18343
|
+
setLoadStates((prevState) => ({
|
|
18344
|
+
...prevState,
|
|
18345
|
+
[index]: true
|
|
18346
|
+
}));
|
|
18347
|
+
console.error("图片加载失败:", error2);
|
|
18348
|
+
};
|
|
18349
|
+
const getLoadState = (pageIndex) => {
|
|
18350
|
+
return loadStates[pageIndex] || false;
|
|
18351
|
+
};
|
|
18352
|
+
y$1(() => {
|
|
18353
|
+
const container = contentRef.current;
|
|
18354
|
+
if (container) {
|
|
18355
|
+
updateVisibleRange();
|
|
18356
|
+
container.addEventListener("scroll", updateVisibleRange);
|
|
18357
|
+
return () => {
|
|
18358
|
+
container.removeEventListener("scroll", updateVisibleRange);
|
|
18359
|
+
};
|
|
18360
|
+
}
|
|
18361
|
+
}, [updateVisibleRange]);
|
|
18265
18362
|
y$1(() => {
|
|
18266
18363
|
scrollToCurrentThumbnail();
|
|
18267
18364
|
}, [props.currentPage]);
|
|
18268
18365
|
return /* @__PURE__ */ u("div", { className: "thumbnail-panel", children: [
|
|
18269
18366
|
/* @__PURE__ */ u("div", { className: "thumbnail-panel-header", children: /* @__PURE__ */ u("h3", { children: "缩略图" }) }),
|
|
18270
18367
|
/* @__PURE__ */ u("div", { className: "thumbnail-panel-content", ref: contentRef, children: props.pages && props.pages.length > 0 && props.pages.map((page, index) => {
|
|
18368
|
+
const isLoaded = getLoadState(index);
|
|
18369
|
+
const isCached = cachedImages.has(index);
|
|
18370
|
+
const isVisible = visibleRange.start <= index && index <= visibleRange.end;
|
|
18271
18371
|
return /* @__PURE__ */ u(
|
|
18272
18372
|
"div",
|
|
18273
18373
|
{
|
|
@@ -18276,13 +18376,19 @@ const ThumbnailPanel = (props) => {
|
|
|
18276
18376
|
handleClick(index);
|
|
18277
18377
|
},
|
|
18278
18378
|
children: [
|
|
18279
|
-
/* @__PURE__ */ u(
|
|
18379
|
+
!isLoaded && /* @__PURE__ */ u(Loading, {}),
|
|
18380
|
+
(isVisible || isCached) && /* @__PURE__ */ u(
|
|
18280
18381
|
"img",
|
|
18281
18382
|
{
|
|
18282
18383
|
src: "".concat(imgBasePath).concat(page.image_url),
|
|
18283
18384
|
alt: page.description,
|
|
18284
18385
|
className: "thumbnail-image",
|
|
18285
|
-
|
|
18386
|
+
onLoad: () => {
|
|
18387
|
+
handleImageLoad(index);
|
|
18388
|
+
},
|
|
18389
|
+
onError: (error2) => {
|
|
18390
|
+
handleImageError(index, error2);
|
|
18391
|
+
}
|
|
18286
18392
|
}
|
|
18287
18393
|
),
|
|
18288
18394
|
/* @__PURE__ */ u("div", { className: "thumbnail-page-number", children: index + 1 })
|
|
@@ -18301,22 +18407,30 @@ const ImagePage = (props) => {
|
|
|
18301
18407
|
height: 0
|
|
18302
18408
|
});
|
|
18303
18409
|
const imgStyle = useComputed(() => {
|
|
18304
|
-
|
|
18305
|
-
|
|
18306
|
-
|
|
18307
|
-
|
|
18308
|
-
|
|
18309
|
-
|
|
18310
|
-
width: "".concat(parentStyle.value.width * props.state.value.scale, "px")
|
|
18311
|
-
});
|
|
18312
|
-
} else if (props.state.value.mode === ImageMode.PAGE) {
|
|
18313
|
-
Object.assign(result, {
|
|
18314
|
-
height: "".concat(parentStyle.value.height * props.state.value.scale, "px")
|
|
18315
|
-
});
|
|
18410
|
+
let result = {};
|
|
18411
|
+
if (isLoading.value) {
|
|
18412
|
+
result = {
|
|
18413
|
+
height: "".concat(parentStyle.value.height * props.state.value.scale, "px"),
|
|
18414
|
+
flexShrink: 0
|
|
18415
|
+
};
|
|
18316
18416
|
} else {
|
|
18317
|
-
|
|
18318
|
-
|
|
18319
|
-
|
|
18417
|
+
result = {
|
|
18418
|
+
transform: "rotate(".concat(props.state.value.rotateMap[props.index] || 0, "deg)"),
|
|
18419
|
+
transition: "transform .3s"
|
|
18420
|
+
};
|
|
18421
|
+
if (props.state.value.mode === ImageMode.WIDTH) {
|
|
18422
|
+
Object.assign(result, {
|
|
18423
|
+
width: "".concat(parentStyle.value.width * props.state.value.scale, "px")
|
|
18424
|
+
});
|
|
18425
|
+
} else if (props.state.value.mode === ImageMode.PAGE) {
|
|
18426
|
+
Object.assign(result, {
|
|
18427
|
+
height: "".concat(parentStyle.value.height * props.state.value.scale, "px")
|
|
18428
|
+
});
|
|
18429
|
+
} else {
|
|
18430
|
+
Object.assign(result, {
|
|
18431
|
+
width: "".concat(contentWidth * props.state.value.scale, "px")
|
|
18432
|
+
});
|
|
18433
|
+
}
|
|
18320
18434
|
}
|
|
18321
18435
|
return result;
|
|
18322
18436
|
});
|
|
@@ -18337,11 +18451,13 @@ const ImagePage = (props) => {
|
|
|
18337
18451
|
};
|
|
18338
18452
|
};
|
|
18339
18453
|
y$1(() => {
|
|
18340
|
-
var _a;
|
|
18341
18454
|
updateParentStyle();
|
|
18342
18455
|
const observer = new ResizeObserver(updateParentStyle);
|
|
18343
|
-
if (
|
|
18344
|
-
|
|
18456
|
+
if (imgRef.current) {
|
|
18457
|
+
if (imgRef.current.parentElement) {
|
|
18458
|
+
observer.observe(imgRef.current.parentElement);
|
|
18459
|
+
}
|
|
18460
|
+
}
|
|
18345
18461
|
return () => {
|
|
18346
18462
|
observer.disconnect();
|
|
18347
18463
|
};
|
|
@@ -18354,7 +18470,7 @@ const ImagePage = (props) => {
|
|
|
18354
18470
|
style: imgStyle.value,
|
|
18355
18471
|
"data-page-index": props.index,
|
|
18356
18472
|
children: [
|
|
18357
|
-
/* @__PURE__ */ u(
|
|
18473
|
+
props.isShowImage ? /* @__PURE__ */ u(
|
|
18358
18474
|
"img",
|
|
18359
18475
|
{
|
|
18360
18476
|
className: "image-content",
|
|
@@ -18368,7 +18484,7 @@ const ImagePage = (props) => {
|
|
|
18368
18484
|
},
|
|
18369
18485
|
loading: "lazy"
|
|
18370
18486
|
}
|
|
18371
|
-
),
|
|
18487
|
+
) : /* @__PURE__ */ u(Loading, {}),
|
|
18372
18488
|
isLoading.value && /* @__PURE__ */ u(Loading, {})
|
|
18373
18489
|
]
|
|
18374
18490
|
}
|
|
@@ -18379,7 +18495,8 @@ const FilePreviewImageGroup = (props) => {
|
|
|
18379
18495
|
const state = controller.state;
|
|
18380
18496
|
const contentRef = A(null);
|
|
18381
18497
|
const isScrolling = useSignal(false);
|
|
18382
|
-
const
|
|
18498
|
+
const [loadedPages, setLoadedPages] = d$2(/* @__PURE__ */ new Set());
|
|
18499
|
+
const computeClosestPage = () => {
|
|
18383
18500
|
if (contentRef.current) {
|
|
18384
18501
|
const containerRect = contentRef.current.getBoundingClientRect();
|
|
18385
18502
|
let closestPage = state.value.currentPage;
|
|
@@ -18397,11 +18514,27 @@ const FilePreviewImageGroup = (props) => {
|
|
|
18397
18514
|
}
|
|
18398
18515
|
}
|
|
18399
18516
|
});
|
|
18517
|
+
return closestPage;
|
|
18518
|
+
}
|
|
18519
|
+
};
|
|
18520
|
+
const handleScroll = throttle(() => {
|
|
18521
|
+
if (contentRef.current) {
|
|
18522
|
+
const closestPage = computeClosestPage();
|
|
18400
18523
|
if (!isScrolling.value && closestPage !== state.value.currentPage) {
|
|
18401
18524
|
controller.updateState({ currentPage: closestPage });
|
|
18402
18525
|
}
|
|
18403
18526
|
}
|
|
18404
18527
|
}, 100);
|
|
18528
|
+
const handleImageResize = () => {
|
|
18529
|
+
if (contentRef.current) {
|
|
18530
|
+
setTimeout(() => {
|
|
18531
|
+
const closestPage = computeClosestPage();
|
|
18532
|
+
if (closestPage !== state.value.currentPage) {
|
|
18533
|
+
controller.updateState({ currentPage: closestPage });
|
|
18534
|
+
}
|
|
18535
|
+
}, 0);
|
|
18536
|
+
}
|
|
18537
|
+
};
|
|
18405
18538
|
const scrollToPage = (pageIndex) => {
|
|
18406
18539
|
if (contentRef.current) {
|
|
18407
18540
|
const pageElement = contentRef.current.querySelector(
|
|
@@ -18421,14 +18554,17 @@ const FilePreviewImageGroup = (props) => {
|
|
|
18421
18554
|
}
|
|
18422
18555
|
});
|
|
18423
18556
|
};
|
|
18424
|
-
const
|
|
18425
|
-
controller.updateState({ currentPage: pageIndex });
|
|
18426
|
-
scrollToPage(pageIndex);
|
|
18557
|
+
const updateIsScrolling = () => {
|
|
18427
18558
|
isScrolling.value = true;
|
|
18428
18559
|
setTimeout(() => {
|
|
18429
18560
|
isScrolling.value = false;
|
|
18430
18561
|
}, 1e3);
|
|
18431
18562
|
};
|
|
18563
|
+
const handlePageClick = (pageIndex) => {
|
|
18564
|
+
controller.updateState({ currentPage: pageIndex });
|
|
18565
|
+
scrollToPage(pageIndex);
|
|
18566
|
+
updateIsScrolling();
|
|
18567
|
+
};
|
|
18432
18568
|
const handleInput = (e2) => {
|
|
18433
18569
|
const target = e2.target;
|
|
18434
18570
|
const newPage = parseInt(target.value) - 1;
|
|
@@ -18455,15 +18591,17 @@ const FilePreviewImageGroup = (props) => {
|
|
|
18455
18591
|
const handleModeChange = (payload) => {
|
|
18456
18592
|
const value = payload.target.value;
|
|
18457
18593
|
controller.switchMode(value);
|
|
18594
|
+
scrollToPage(state.value.currentPage);
|
|
18458
18595
|
};
|
|
18459
18596
|
y$1(() => {
|
|
18460
|
-
|
|
18461
|
-
|
|
18597
|
+
if (contentRef.current) {
|
|
18598
|
+
contentRef.current.addEventListener("scroll", handleScroll);
|
|
18599
|
+
}
|
|
18462
18600
|
preloadImages();
|
|
18463
18601
|
props.onInitialization();
|
|
18464
18602
|
return () => {
|
|
18465
|
-
var
|
|
18466
|
-
(
|
|
18603
|
+
var _a;
|
|
18604
|
+
(_a = contentRef.current) == null ? void 0 : _a.removeEventListener("scroll", handleScroll);
|
|
18467
18605
|
};
|
|
18468
18606
|
}, []);
|
|
18469
18607
|
return /* @__PURE__ */ u("div", { className: "file-preview-image-group", children: [
|
|
@@ -18471,7 +18609,9 @@ const FilePreviewImageGroup = (props) => {
|
|
|
18471
18609
|
"div",
|
|
18472
18610
|
{
|
|
18473
18611
|
className: "image-group-left-container",
|
|
18474
|
-
style: {
|
|
18612
|
+
style: {
|
|
18613
|
+
visibility: state.value.showThumbnailPanel ? "visible" : "hidden"
|
|
18614
|
+
},
|
|
18475
18615
|
children: /* @__PURE__ */ u(
|
|
18476
18616
|
ThumbnailPanel,
|
|
18477
18617
|
{
|
|
@@ -18493,12 +18633,29 @@ const FilePreviewImageGroup = (props) => {
|
|
|
18493
18633
|
handleScroll();
|
|
18494
18634
|
},
|
|
18495
18635
|
children: state.value.items && state.value.items.length > 0 && state.value.items.map((page, index) => {
|
|
18636
|
+
const bufferRange = 1;
|
|
18637
|
+
const startRange = Math.max(
|
|
18638
|
+
0,
|
|
18639
|
+
state.value.currentPage - bufferRange
|
|
18640
|
+
);
|
|
18641
|
+
const endRange = Math.min(
|
|
18642
|
+
state.value.items.length - 1,
|
|
18643
|
+
state.value.currentPage + bufferRange
|
|
18644
|
+
);
|
|
18645
|
+
const shouldRender = index >= startRange && index <= endRange;
|
|
18646
|
+
const shouldKeepLoaded = loadedPages.has(index);
|
|
18647
|
+
if (shouldRender) {
|
|
18648
|
+
if (!loadedPages.has(index)) {
|
|
18649
|
+
setLoadedPages((prev) => new Set(prev).add(index));
|
|
18650
|
+
}
|
|
18651
|
+
}
|
|
18496
18652
|
return /* @__PURE__ */ u(
|
|
18497
18653
|
ImagePage,
|
|
18498
18654
|
{
|
|
18499
18655
|
page,
|
|
18500
18656
|
index,
|
|
18501
|
-
state
|
|
18657
|
+
state,
|
|
18658
|
+
isShowImage: shouldRender || shouldKeepLoaded
|
|
18502
18659
|
},
|
|
18503
18660
|
index
|
|
18504
18661
|
);
|
|
@@ -18566,8 +18723,13 @@ const FilePreviewImageGroup = (props) => {
|
|
|
18566
18723
|
value: state.value.currentPage + 1,
|
|
18567
18724
|
min: "1",
|
|
18568
18725
|
max: state.value.total || 1,
|
|
18569
|
-
|
|
18726
|
+
onBlur: (event) => {
|
|
18570
18727
|
handleInput(event);
|
|
18728
|
+
},
|
|
18729
|
+
onKeyDown: (event) => {
|
|
18730
|
+
if (event.key === "Enter") {
|
|
18731
|
+
handleInput(event);
|
|
18732
|
+
}
|
|
18571
18733
|
}
|
|
18572
18734
|
}
|
|
18573
18735
|
),
|
|
@@ -18600,6 +18762,7 @@ const FilePreviewImageGroup = (props) => {
|
|
|
18600
18762
|
className: "control-btn",
|
|
18601
18763
|
onClick: (event) => {
|
|
18602
18764
|
controller.zoomOutPreview(event);
|
|
18765
|
+
handleImageResize();
|
|
18603
18766
|
},
|
|
18604
18767
|
children: /* @__PURE__ */ u("span", { className: "icon", children: /* @__PURE__ */ u(ZoomOutSvg, {}) })
|
|
18605
18768
|
}
|
|
@@ -18615,6 +18778,7 @@ const FilePreviewImageGroup = (props) => {
|
|
|
18615
18778
|
className: "control-btn",
|
|
18616
18779
|
onClick: (event) => {
|
|
18617
18780
|
controller.zoomInPreview(event);
|
|
18781
|
+
handleImageResize();
|
|
18618
18782
|
},
|
|
18619
18783
|
children: /* @__PURE__ */ u("span", { className: "icon", children: /* @__PURE__ */ u(ZoomInSvg, {}) })
|
|
18620
18784
|
}
|
|
@@ -18627,6 +18791,7 @@ const FilePreviewImageGroup = (props) => {
|
|
|
18627
18791
|
className: "control-btn",
|
|
18628
18792
|
onClick: () => {
|
|
18629
18793
|
controller.reSet();
|
|
18794
|
+
handleImageResize();
|
|
18630
18795
|
},
|
|
18631
18796
|
children: /* @__PURE__ */ u("span", { className: "icon", children: /* @__PURE__ */ u(ResetSvg, {}) })
|
|
18632
18797
|
}
|
|
@@ -18634,9 +18799,6 @@ const FilePreviewImageGroup = (props) => {
|
|
|
18634
18799
|
] }) })
|
|
18635
18800
|
] });
|
|
18636
18801
|
};
|
|
18637
|
-
const Loading = ({ size = 24 }) => {
|
|
18638
|
-
return /* @__PURE__ */ u("div", { className: "loading-mask", children: /* @__PURE__ */ u("div", { className: "loading-spinner", children: /* @__PURE__ */ u(LoaddingSvg, { size }) }) });
|
|
18639
|
-
};
|
|
18640
18802
|
const FilePreviewShell = (props) => {
|
|
18641
18803
|
y$1(() => {
|
|
18642
18804
|
document.addEventListener("click", handleClickOutside, true);
|
|
@@ -18882,7 +19044,7 @@ class FilePreviewImageController extends FilePreviewItemController {
|
|
|
18882
19044
|
zoomOutPreview(_event) {
|
|
18883
19045
|
const { scale } = this.state.value;
|
|
18884
19046
|
this.updateState({
|
|
18885
|
-
scale: Math.max(scale - 0.1, 0.
|
|
19047
|
+
scale: Math.max(scale - 0.1, 0.5)
|
|
18886
19048
|
});
|
|
18887
19049
|
}
|
|
18888
19050
|
/**
|
|
@@ -19765,6 +19927,19 @@ class FilePreviewMDController extends FilePreviewTextController {
|
|
|
19765
19927
|
}
|
|
19766
19928
|
}
|
|
19767
19929
|
class FilePreviewHtmlController extends FilePreviewTextController {
|
|
19930
|
+
/**
|
|
19931
|
+
* 获取内容
|
|
19932
|
+
*/
|
|
19933
|
+
async getContent() {
|
|
19934
|
+
const options = this.filePreviewShell.getOptions();
|
|
19935
|
+
const { fileId, fileCat } = this.filePreviewShell.getState();
|
|
19936
|
+
try {
|
|
19937
|
+
const content = await options.getContent(fileId, "html", fileCat);
|
|
19938
|
+
return content || "";
|
|
19939
|
+
} catch (error2) {
|
|
19940
|
+
return error2.message || "";
|
|
19941
|
+
}
|
|
19942
|
+
}
|
|
19768
19943
|
}
|
|
19769
19944
|
class FilePreviewItemDispatcher {
|
|
19770
19945
|
/**
|